import os
import signal

# fork进程之前添加，创建进程后由系统进程统一管理子进程的退出状态
signal.signal(signal.SIGCHLD, signal.SIG_IGN)

pid = os.fork()
if pid < 0:
    # 创建失败
    print('failed')
elif pid == 0:
    # 新进程Pid为0
    print('child process')
else:
    # 父进程Pid返回新进程的Pid
    print('parent process')

